package com.letu.core.excel.bean;

import com.letu.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @ClassName JudgeTypeEnum
 * @Description Excel boolean类型转换
 * @Author yuwx
 * @Date 2021/9/4 15:32
 * @Version 1.0
 **/
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "JudgeTypeEnum", description = "判断类型")
public enum JudgeTypeEnum implements BaseEnum {
    Y("是"),
    N("否"),
    ;
    @ApiModelProperty(value = "描述")
    private String desc;

    /**
    *Description 类型转boolean
    *@Date 13:13 2021/9/6
    *@param judgeTypeEnum
    *@return java.lang.Boolean
    *@Author yuwx
    **/
    public static Boolean convertBoolean(JudgeTypeEnum judgeTypeEnum) {
        if (Objects.isNull(judgeTypeEnum)) {
            return false;
        }
        if (Y.equals(judgeTypeEnum)) {
            return true;
        }
        return false;
    }

    public Integer convertToInteger() {
        return Y.equals(this)? 1 : 0;
    }
}
